package com.iwhalecloud.uncc.web.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @author zq
 * @description 统一封装结果
 */
@Data
public class Result implements Serializable {

    private int code;
    private String message;
    private Object data;

    public static Result success(Object data){
        return success(200,"操作成功",data);
    }

    public static Result success(int code , String message , Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result fail(String message){
        return success(400,message,null);
    }

    public static Result fail(String message , Object data){
        return success(400,message,data);
    }

    public static Result fail(int code , String message , Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
}
